<?php
/**
 * Widget for displaying content of three categories (triple widget) on home page
 *
 * Used for both single and index/archive/search.
 *
 * @package WordPress
 * @subpackage lebanontimes
 * @since Lebanon Times 1.0
 */

include dirname(__FILE__)."/categoryMapping.php";
?>

<div class="horizontalWidget widgetMargin">
    <div style="background-color: #FFF; width: 100%; height: 45px; clear: both;">
        <div class="tabActive">
            <span style='float: right'><?php echo get_the_category_by_ID( $categoryMapping['last-video'][0] );?></span>
        </div>
    </div>
    <div class="content">
        <?php $posts = get_posts("category={$categoryMapping['last-video'][0]}&numberposts=0");
            add_filter( 'the_title', 'max_title_length');
            for($i=0; $i<$categoryMapping['last-video'][1] && $i < count($posts); $i++) {
                $post = $posts[$i]; ?>
                <div class="thumbnail videoBackground">
                    <a class="thumblink" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
                        <img class="video-thumb" src="http://i.ytimg.com/vi/<?php
                        // this is where the custom field prints images for each post
                        $values = get_post_custom_values("video_id"); echo $values[0]; ?>/0.jpg" width='180' alt="<?php the_title(); ?> Thumbnail" />
                        <img src="<?php echo get_template_directory_uri(); ?>/images/red-play-btn.png" class="play-button">
                    </a>
                </div>
                <a href="<?php the_permalink() ?>" rel="bookmark">
                    <?php the_title(); ?>
                </a>
        <?php 
            } 
            remove_filter( 'the_title', 'max_title_length');
        ?>
    </div>
</div>